(function () {

    class Animal {
        name: string
        age: number

        // 构造函数
        // 对象创建时调用
        constructor(name: string, age: number) {
            // this 表示当前类的实例
            this.name = name
            this.age = age
        }

        sayHello() {
            console.log('动物叫。。。')
        }
    }

    class Dog extends Animal {
        sayHello() {
            console.log('Dog叫。。。')
        }
        run() {
            console.log(`${this.name}在跑`)
        }
    }

    class Cat extends Animal {
        sayHello() {
            console.log('Cat叫。。。')
        }
    }


    const dog = new Dog('旺财', 5)
    console.log(dog)
    dog.sayHello()
    dog.run()

    const cat = new Cat('咪咪', 5)
    console.log(cat)
    cat.sayHello()

})();
